<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  
  <title>7-机器人SLAM建图 | ChenBlue | 飞雪连天射白鹿 笑书神侠倚碧鸳</title>

  
  <meta name="author" content="ChenBlue">
  

  
  <meta name="description" content="学习笔记">
  

  
  
  <meta name="keywords" content="ROS">
  

  <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">

  <meta property="og:title" content="7-机器人SLAM建图"/>

  <meta property="og:site_name" content="ChenBlue"/>

  
  <meta property="og:image" content="/blog/favicon.ico"/>
  

  <link href="/blog/favicon.ico" rel="icon">
  <link rel="alternate" href="/blog/atom.xml" title="ChenBlue" type="application/atom+xml">
  <link rel="stylesheet" href="/blog/css/style.css" media="screen" type="text/css">
<meta name="generator" content="Hexo 5.4.0"></head>


<body>
<div class="blog">
  <div class="content">

    <header>
  <div class="site-branding">
    <h1 class="site-title">
      <a href="/blog/">ChenBlue</a>
    </h1>
    <p class="site-description">飞雪连天射白鹿 笑书神侠倚碧鸳</p>
  </div>
  <nav class="site-navigation">
    <ul>
      
    </ul>
  </nav>
</header>

    <main class="site-main posts-loop">
    <article>

  
    
    <h3 class="article-title"><span>7-机器人SLAM建图</span></h3>
    
  

  <div class="article-top-meta">
    <span class="posted-on">
      <a href="/blog/2021/04/12/7-机器人SLAM建图/" rel="bookmark">
        <time class="entry-date published" datetime="2021-04-12T12:39:03.000Z">
          2021-04-12
        </time>
      </a>
    </span>
  </div>


  

  <div class="article-content">
    <div class="entry">
      
        <h1 id="常用的-SLAM-功能包应用"><a href="#常用的-SLAM-功能包应用" class="headerlink" title="常用的 SLAM 功能包应用"></a>常用的 SLAM 功能包应用</h1><h2 id="gmapping"><a href="#gmapping" class="headerlink" title="gmapping"></a>gmapping</h2><p><strong>gmapping 功能包</strong></p>
<ul>
<li>基于激光雷达</li>
<li>Rao-Blackwellized粒子滤波算法</li>
<li>二维栅格地图</li>
<li>需要机器人提供里程计信息</li>
<li>OpenSlam开源算法</li>
<li>输出地图话题:</li>
<li>nav_msgs/OccupancyGrid。</li>
</ul>
<pre class="language-none"><code class="language-none">graph TD
A(即时定位与地图建模 gmapping)

B(深度信息)--&gt;A

C(IMU信息)--&gt;A 

D(里程计信息)--&gt;A
</code></pre>
<p><strong><center>gmapping 功能包的总体框架</center></strong></p>
<p><strong>安装gmapping</strong></p>
<pre class="language-none"><code class="language-none">sudo apt-get install ros-melodic-gmapping</code></pre>
<p><strong><center>gmapping 功能包中的话题和服务</center></strong></p>
<table>
<thead>
<tr>
<th align="left"></th>
<th align="left">名称</th>
<th align="left">类型</th>
<th align="left">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Topic 订阅</td>
<td align="left">tf</td>
<td align="left">tf/tfMessage</td>
<td align="left">用于激光雷达坐标系，基座标系。里程计坐标系之间的变换</td>
</tr>
<tr>
<td align="left">Topic 订阅</td>
<td align="left">scan</td>
<td align="left">sensor_msgs/LaserScan</td>
<td align="left">激光雷达扫描数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">map_metedata</td>
<td align="left">nav_msgs/MapMeteData</td>
<td align="left">发布地图Meta数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">map</td>
<td align="left">nav_msgs/OccupancyGrid</td>
<td align="left">发布地图栅格数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">~entropy</td>
<td align="left">std_msgs/Float64</td>
<td align="left">发布机器人姿态分布熵的估计</td>
</tr>
<tr>
<td align="left">Service</td>
<td align="left">dynamic_map</td>
<td align="left">nav_msgs/GetMap</td>
<td align="left">获取地图数据</td>
</tr>
</tbody></table>
<p><strong><center>gampping 功能包中的TF变换</center></strong></p>
<table>
<thead>
<tr>
<th></th>
<th>TF变换</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>必须的TF坐标变换</td>
<td><scan frame>-&gt;base_link</scan></td>
<td>激光雷达坐标系之间的变换</td>
</tr>
<tr>
<td></td>
<td>base_link-&gt;odom</td>
<td>基座标系与里程计坐标系之间的变换。一般由里程计节点发布</td>
</tr>
<tr>
<td>发布的TF坐标变换</td>
<td>map-&gt;odom</td>
<td>地图坐标系与机器人里程计坐标系之间的变换。估计机器人在地图中的位置</td>
</tr>
</tbody></table>
<p><strong>保存地图</strong></p>
<pre class="language-none"><code class="language-none">rosrun map_server map_saver -f cloister_gmapping</code></pre>
<h2 id="hector"><a href="#hector" class="headerlink" title="hector"></a>hector</h2><p><strong>hector 功能包</strong></p>
<ul>
<li>基于激光雷达</li>
<li>高斯牛顿方法</li>
<li>二维栅格地图</li>
<li><strong>不需要机器人提供里程计信息</strong></li>
<li>输出地图话题:</li>
<li>nav_msgs/OccupancyGrid。</li>
</ul>
<pre class="language-none"><code class="language-none">graph TD
A(即时定位与地图建模 hector)

B(深度信息)--&gt;A</code></pre>
<p><strong><center>hector_slam 功能包的总体框架</center></strong></p>
<p><strong>安装hector_slam</strong></p>
<pre class="language-none"><code class="language-none">$ git clone https:&#x2F;&#x2F;github.com&#x2F;tu-darmstadt-ros-pkg&#x2F;hector_slam.git</code></pre>
<p><strong><center>hector 功能包中的话题和服务</center></strong></p>
<table>
<thead>
<tr>
<th align="left"></th>
<th align="left">名称</th>
<th align="left">类型</th>
<th align="left">描述</th>
</tr>
</thead>
<tbody><tr>
<td align="left">Topic 订阅</td>
<td align="left">syscommand</td>
<td align="left">std_msgs/String</td>
<td align="left">系统命令</td>
</tr>
<tr>
<td align="left">Topic 订阅</td>
<td align="left">scan</td>
<td align="left">sensor_msgs/LaserScan</td>
<td align="left">激光雷达扫描数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">map_metedata</td>
<td align="left">nav_msgs/MapMeteData</td>
<td align="left">发布地图Meta数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">map</td>
<td align="left">nav_msgs/OccupancyGrid</td>
<td align="left">发布地图栅格数据</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">slam_out_pose</td>
<td align="left">geometry_msgs/PoseStamped</td>
<td align="left">估计的机器人位置（没用协方差）</td>
</tr>
<tr>
<td align="left">Topic 发布</td>
<td align="left">poseupdate</td>
<td align="left">geometry_msgs/PoseWithCovarianceStamped</td>
<td align="left">估计的机器人位置（具有高斯估计的不确定性）</td>
</tr>
<tr>
<td align="left">Service</td>
<td align="left">dynamic_map</td>
<td align="left">nav_msgs/GetMap</td>
<td align="left">获取地图数据</td>
</tr>
</tbody></table>
<p><strong><center>hector 功能包中的TF变换</center></strong></p>
<table>
<thead>
<tr>
<th></th>
<th>TF变换</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>必须的TF坐标变换</td>
<td><scan frame>-&gt;base_link</scan></td>
<td>激光雷达坐标系之间的变换</td>
</tr>
<tr>
<td></td>
<td>base_link-&gt;odom</td>
<td>基座标系与里程计坐标系之间的变换。一般由里程计节点发布</td>
</tr>
<tr>
<td>发布的TF坐标变换</td>
<td>map-&gt;odom</td>
<td>地图坐标系与机器人里程计坐标系之间的变换。估计机器人在地图中的位置</td>
</tr>
</tbody></table>
<h2 id="cartographer"><a href="#cartographer" class="headerlink" title="cartographer"></a>cartographer</h2><p><strong>cartographer 功能包</strong></p>
<ul>
<li>2016年10月5日，谷歌开源</li>
<li>基于图网络的优化方法</li>
<li>二维或三维条件下的定位及建图功能</li>
<li>设计目的是在计算资源有限的情况下，实时获取相对较高精度的2D地图</li>
<li>主要基于激光雷达</li>
<li>后续会支持更多传感器和机器人平台,同时不断增加新的功能。</li>
</ul>
<p><strong>安装 cartographer</strong></p>
<pre class="language-none"><code class="language-none">$ sudo apt-get install ros-melodic-cartographer-*</code></pre>
<p><strong>保存地图</strong></p>
<pre class="language-none"><code class="language-none">$ rosservice call &#x2F;finish_trajectory 0
$ rosservice call &#x2F;write_state &quot;&#123;filename: &#39;$&#123;HOME&#125;&#x2F;mymap.pbstream&#39;&#125;&quot;
$ rosrun cartographer_ros cartographer_pbstream_to_ros_map-map_filestem&#x3D;$&#123;HOME&#125;&#x2F;mymap-pbstream_filename&#x3D;$&#123;HOME&#125;&#x2F;mymap.pbstream-resolution&#x3D;0.05
</code></pre>
<h2 id="rtabmap"><a href="#rtabmap" class="headerlink" title="rtabmap"></a>rtabmap</h2><p><strong>安装 rtabmap</strong></p>
<pre class="language-none"><code class="language-none">$ sudo apt-get install ros-melodic-rtabmap-ros</code></pre>
<p><strong>查看建图结果</strong></p>
<pre class="language-none"><code class="language-none">$ rtabmap-databaseViewer ~&#x2F;.ros&#x2F;rtabmap.db</code></pre>



      
    </div>

  </div>

  <div class="article-footer">
    <div class="article-meta pull-left">

    
      

    <span class="post-categories">
      <i class="icon-categories"></i>
        <a href="/blog/categories/ROS-学习笔记/">ROS 学习笔记</a>
    </span>
    

    
    

    <span class="post-tags">
      <i class="icon-tags"></i>
        <a href="/blog/tags/ROS/">ROS</a>
    </span>
    

    </div>

    
  </div>
</article>

  









    </main>

    <footer class="site-footer">
  <p class="site-info">
    Proudly powered by <a href="https://hexo.io/" target="_blank">Hexo</a> and
    Theme by <a href="https://github.com/CodeDaraW/Hacker" target="_blank">Hacker</a>
    </br>
    
    &copy; 2023 ChenBlue
    
  </p>
</footer>
    
    
  </div>
</div>
</body>
</html>